﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>
        .layui-input {
            height: 25px;
        }

        .layui-form-item .layui-input-inline {
            float: left;
            width: 140px;
            margin-right: 10px;
        }

        .layui-form-pane .layui-form-label {
            width: 80px;
            padding: 2px 5px;
            height: 25px;
            line-height: 20px;
            border-width: 1px;
            border-style: solid;
            border-radius: 2px 0 0 2px;
            text-align: center;
            background-color: #FBFBFB;
            overflow: hidden;
            box-sizing: border-box;
        }
    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset">
                <legend>交付详情</legend>
                <div style="margin: 5px 10px 5px 10px" class="layui-form-pane">
                    <form class="layui-form" action="" lay-filter="example">
                        <input type="hidden" name="ID" value="" id="IndexID" />
                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">流程卡号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="Code" lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline" style="display:none;">
                                <label class="layui-form-label">产品编号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="GoodsCode" lay-verify="required" autocomplete="off" class="layui-input" id="GoodsCode" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">产品型号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="GoodsModel" lay-verify="required" autocomplete="off" class="layui-input" id="GoodsModel" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline" style="display:none;">
                                <label class="layui-form-label">晶圆编号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="SourceGoodsCode" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsCode" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">晶圆型号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="SourceGoodsModel" lay-verify="required" autocomplete="off" class="layui-input" id="SourceGoodsModel" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">晶圆尺寸</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="SourceGoodsSize" lay-verify="required" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">芯片尺寸</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="GoodsSize" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">投片数量</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="TouQty" lay-verify="required|number" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">设计数量</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="SheQty" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">正背面金属</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="ZhengBei" autocomplete="off" class="layui-input" disabled="disabled">
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                    @*<button class="layui-btn layui-btn-sm layui-btn-danger data-delete-btn" lay-event="delete"> 删除 </button>*@
                </div>
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
                <a class="layui-btn layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
                <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
            </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script src="~/layuimini/js/lay-config.js"></script>
    <script>
        layui.use(['form', 'table', 'miniTab'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                miniTab = layui.miniTab;


            form.val('example', {
                "ID": "@ViewBag.model.ID"
                , "GoodsID": "@ViewBag.model.GoodsID"
                , "GoodsCode": "@ViewBag.model.GoodsCode"
                , "GoodsName": "@ViewBag.model.GoodsName"
                , "GoodsModel": "@ViewBag.model.GoodsModel"
                , "GoodsSize": "@ViewBag.model.GoodsSize"
                , "SourceGoodsID": "@ViewBag.model.SourceGoodsID"
                , "SourceGoodsCode": "@ViewBag.model.SourceGoodsCode"
                , "SourceGoodsName": "@ViewBag.model.SourceGoodsName"
                , "SourceGoodsModel": "@ViewBag.model.SourceGoodsModel"
                , "SourceGoodsSize": "@ViewBag.model.SourceGoodsSize"
                , "Code": "@ViewBag.model.Code"
                , "TouQty": "@ViewBag.model.TouQty"
                , "SheQty": "@ViewBag.model.SheQty"
                , "ZhengBei": "@ViewBag.model.ZhengBei"
            })

            table.render({
            elem: '#table',
            method: 'post',
            url: '@Url.Action("JiaoFuListAsync", "Bill2")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               , limitName: 'PageSize' //每页数据量的参数名，默认：limit

            },
            where: {
                IndexID:@ViewBag.model.ID,
            },
            cellMinWidth:120,
            toolbar: '#toolbarDemo',
            defaultToolbar: [{ layEvent: 'refresh', icon: 'layui-icon-refresh', title: '刷新' },'filter', 'exports', 'print'],
            cols: [[
                { type: "checkbox", width: 50 },
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'ID', title: 'ID', width: 100, hide: true },
                { field: 'CreateTime', title: '交付时间' },
                { field: 'HQty', title: '划片数量' },
                { field: 'Qty', title: '交付数量' },
                { field: 'Number', title: '交付批次' },
                { field: 'Remark', title: '备注' },
                { fixed: 'right', title: '操作', toolbar: '#currentTableBar', width: 250 }
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: false,
            //skin: 'line',
            //totalRow: true,
            height: 'full-220',
            size:'sm',
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false
        });

        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                    var index = layer.open({
                        title: '添加交付',
                        type: 2,
                        shade: 0.2,
                        maxmin:true,
                        shadeClose: true,
                        area: ['600px', '550px'],
                        content: '@Url.Action("JiaoFuEdit", "Bill2")?IndexID=@ViewBag.model.ID',
                        end: function () {
                            RefreshTable();
                        }
                    });
                    $(window).on("resize", function () {
                        layer.full(index);
                    });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('table')
                    , data = checkStatus.data;
                if (data.length == 0) {
                    layer.msg('请选择您要删除的数据！', { icon: 5, time: 2000 });
                    return;
                }

                var arr = [];
                for (var i = 0; i < data.length; i++) {
                    arr.push(data[i].ID);
                }

                var ids = arr.join(",");


                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("JiaoFuDelAsync", "Bill2")',
                        type: "post",
                        dataType: "json",
                        data: { IDs: ids },
                        success: function (data) {
                            //Info,Success,Warning,Error
                            var type = data.Type;
                            if (type == 1) {
                                layer.msg(data.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(data.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'refresh') {
                RefreshTable();
            }
        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {

                var index = layer.open({
                    title: '修改交付',
                    type: 2,
                    shade: 0.2,
                    maxmin:true,
                    shadeClose: true,
                    area: ['600px', '550px'],
                    content: '@Url.Action("JiaoFuEdit", "Bill2")?IndexID=@ViewBag.model.ID'+'&ID='+data.ID,
                    end: function () {
                        RefreshTable();
                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            } else if (obj.event === 'delete') {
                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("JiaoFuEditAsync", "Bill2")',
                        type: "post",
                        dataType: "json",
                        data: { Qty: 0 ,IndexID:@ViewBag.model.ID,ID: -data.ID },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
            } else if (obj.event === 'details') {
                miniTab.openNewTabByIframe({
                    href: '@Url.Action("DetailsList", "Bill2")' + '?ID=' + data.ID,
                    title: "生产任务单详情",
                });
                return false;
            }
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    IndexID:@ViewBag.model.ID,

                }
            }, 'data');

        }

    });
    </script>
</body>
</html>